#ifndef _WRITEDATA_H_
#define _WRITEDATA_H_

#ifdef _WIN32
#   include <windows.h>
#   include <winsock2.h>
#endif

#include <unistd.h>
#include <time.h>
#include <string.h>
#include "mysql.h"
#include "uv.h"
#include "loomserver.h"
#include "loomtype.h"

#define MAX_BIND_PARAMS


typedef struct {
    char a;
    char b;
    short c;
    int d;
} type_t;

typedef struct {

    char a;
    int d;
    short c;
    char b;

} type2_t;


int parse_recved_data(uv_stream_t* handle, const char *buffer, uint32_t bufferlen);
int save_collector_data(request_body_t *reqbody, uint16_t repeater, loom_data_t loomcmds[], uint16_t cmdnums, uv_buf_t *reply_context);
int saveToDB(int routerId, loom_data_t *loomcmds, int cmdlen);
time_t getDataTimestamp(uint8_t bcddate[]);

uint16_t create_reply_context(uint16_t clicmd, uv_buf_t *uvbuffer, uint16_t repeaterid, int retcode);
int get_loomstatus(loom_status_t loomstatus);
uint8_t calc_check_flag(uint16_t datalen, uint8_t loomcmd, uint8_t *clibuffer);

#endif /*_WRITEDATA_H_*/
